package com.vertx.mall;

import com.vertx.web.verticle.AbstractImplVerticle;
import io.vertx.config.ConfigRetriever;
import io.vertx.config.ConfigRetrieverOptions;
import io.vertx.config.ConfigStoreOptions;
import io.vertx.core.DeploymentOptions;
import io.vertx.core.Vertx;
import io.vertx.core.json.JsonObject;
import org.apache.log4j.Logger;
import java.io.File;

/**
 * 描述: run main
 * 创建人:hzw
 * 创建时间: 2018/4/17 16:48
 **/
public class MainVerticle extends AbstractImplVerticle {

    private static final Logger logger = Logger.getLogger(MainVerticle.class);

    public static void main(String[] args) {
        try {
            Vertx vertx=Vertx.vertx();
            ConfigStoreOptions file=new ConfigStoreOptions()
                    .setType("file").setFormat("json").setConfig(new JsonObject().put("path","conf"+ File.separator+"config.json"));
            ConfigRetrieverOptions configRetrieverOptions=new ConfigRetrieverOptions().addStore(file);
            ConfigRetriever retriever=ConfigRetriever.create(vertx,configRetrieverOptions);
            retriever.getConfig(rs->{
                logger.info(rs.result().toString());
                vertx.deployVerticle(MainVerticle.class.getName(),new DeploymentOptions().setConfig(rs.result()));
            });
        } catch (Exception e) {
            e.printStackTrace();
            logger.error("启动vertx-mall失败!");
        }
    }

}
